﻿using LyData.Data.Xml;
using System;
using System.Collections;
using System.Data;
using System.Web;

public class Website
{
    protected string _language;

    public Website()
    {
        int num;
        string s = HttpContext.Current.Request.QueryString["Language"];
        if (!int.TryParse(s, out num))
        {
            s = "0";
        }
        this._language = s;
    }

    public static string GetHtmlValue(string showName)
    {
        Website website = new Website();
        if (showName.ToLower() == "websitetitle")
        {
            return (website.GetValue(showName) + " - Powered by ShanRui.Net");
        }
        return website.GetValue(showName);
    }

    public static string GetLanguage()
    {
        return "0";
    }

    public static string GetMemberAgreementHtmlValue(string key)
    {
        Website website = new Website();
        return website.GetMemberAgreementValue(key);
    }

    public string GetMemberAgreementValue(string key)
    {
        DataRow row = new XmlProvider(HttpContext.Current.Server.MapPath("~/App_Data/RegisterAgreement.xml")).ReadNode(string.Format("descendant::MemberAgreement[Language='{0}']", this._language));
        try
        {
            return (string) row[key];
        }
        catch
        {
            return "";
        }
    }

    public static string GetMenuConfigHtmlValue(string key)
    {
        Website website = new Website();
        return website.GetMenuConfigValue(key);
    }

    public string GetMenuConfigValue(string key)
    {
        DataRow row = new XmlProvider(HttpContext.Current.Server.MapPath("~/App_Data/MenuConfig.xml")).ReadNode(string.Format("descendant::MenuConfig[Language='{0}']", this._language));
        try
        {
            return (string) row[key];
        }
        catch
        {
            return "";
        }
    }

    public static string GetUICulture()
    {
        Website website = new Website();
        string language = website.Language;
        SortedList list = new SortedList();
        XmlProvider provider = new XmlProvider();
        provider.FilePath = HttpContext.Current.Server.MapPath("~/App_Data/Website.xml");
        return (string) provider.ReadNode("descendant::LanguageList", "Value", "Culture")[language];
    }

    public string GetValue(string showName)
    {
        DataRow row = new XmlProvider(HttpContext.Current.Server.MapPath("~/App_Data/Website.xml")).ReadNode(string.Format("descendant::Info[Language='{0}']", this._language));
        try
        {
            return (string) row[showName];
        }
        catch
        {
            return "";
        }
    }

    public static bool IsURLRewriter()
    {
        return false;
    }

    public string Language
    {
        get
        {
            return this._language;
        }
        set
        {
            this._language = value;
        }
    }
}

